package com.example.video.plateRecognition.application.command;

import com.example.video.plateRecognition.client.dto.LicensePlateListQry;
import com.example.video.plateRecognition.infrastructure.manage.VehicleManage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.time.format.DateTimeFormatter;

@Component
public class LicensePlateListQryExe {

    private static final Logger logger = LoggerFactory.getLogger(LicensePlateListQryExe.class);

    public static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    public void execute(LicensePlateListQry qry){
        VehicleManage manage = new VehicleManage();

        // 初始化
        manage.initDevice();

        logger.info("开始登录");

        manage.login_V40(qry.getIp(),(short) 8000,qry.getUsername(),qry.getPassword());

        String response = manage.searchVehicleList(qry.getPlateNumber(), qry.getChannel(), qry.getNumber());
        logger.info("查询返回的报文："+response);
        //用户注销，释放SDK
        manage.deviceLogout();
    }
}
